package com.example.myapplication

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.Toast
import com.example.myapplication.model.ResultOV
import com.example.myapplication.model.Student
import com.example.myapplication.utils.HttpUtil
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import kotlinx.android.synthetic.main.activity_second.*
import okhttp3.Call
import okhttp3.Callback
import okhttp3.Response
import java.io.IOException

class SecondActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_second)
        var students:List<Student>?=null
        HttpUtil.sendOkHttpRequest("http://10.17.218.37:9100/StudentSystem/listStudents",
            object: Callback {
                override fun onFailure(call: Call, e: IOException) {
                    Log.e("MainActivity","发生错误了")
                }

                override fun onResponse(call: Call, response: Response) {
//                    val resultData=response.body?.string()
//                    val type=object :TypeToken<List<Student>>(){}.type
//                     students=Gson().fromJson<List<Student>>(resultData,type)
                }
            })
            second_btn01.setOnClickListener{
                val intent=Intent(this,FourthActivity::class.java)
                startActivity(intent)
//                if(students!=null)
//                    Toast.makeText(this,students.toString(),Toast.LENGTH_LONG).show()
            }
    }
    }
